/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网.简单题.两数之和
 */

class Solution {
    /**
     *
     * @param numbers int整型一维数组
     * @param target int整型
     * @return int整型一维数组
     */
    public int[] twoSum (int[] numbers, int target) {
        // write code here
        int[] ret = new int[]{-1,-1};
        for(int i = 0; i < numbers.length - 1; i++) {
            //节省时间的关键，否则运行超时
            if(numbers[i] > target){
                continue;
            }
            for(int j = i + 1; j < numbers.length; j++) {
                if(numbers[i] + numbers[j] == target){
                    ret[0] = i + 1;
                    ret[1] = j + 1;
                    return ret;
                }
            }
        }
        return ret;
    }
}

public class Test {
}
